package com.anjiplus.template.gaea.business.config;

import com.anjiplus.template.gaea.business.util.MyStringEncryptor;
import com.ulisesbocchio.jasyptspringboot.configuration.EnableEncryptablePropertiesConfiguration;
import org.apache.commons.lang3.StringUtils;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * Jasypt 配置
 *
 * @author lucky_cube
 */
@Configuration
@Import({EnableEncryptablePropertiesConfiguration.class})
public class JasyptAutoConfiguration {
    public JasyptAutoConfiguration() {
    }

    @Bean("myStringEncryptor")
    public StringEncryptor myStringEncryptor() {
        return new MyStringEncryptor(StringUtils.isNotEmpty(System.getProperty("jasypt.encryptor.password"))?System.getProperty("jasypt.encryptor.password"):"oHQib9ILyl4q8nLapDqC", MyStringEncryptor.PBE_ALGORITHMS_MD5_TRIPLEDES);
    }
}
